package com.xyhua.houseproperty.utils;

import com.xyhua.houseproperty.dto.ResultMsg;
import com.xyhua.houseproperty.entity.User;

import cn.hutool.core.lang.Validator;
import cn.hutool.core.util.StrUtil;

/**
 * description: UserHelper <br>
 * date: 2020/3/31 3:23 下午 <br>
 * author: huaxiansheng <br>
 * version: 1.0 <br>
 */
public class UserHelper {

    public static ResultMsg validate(User acount) {
        if (StrUtil.isBlank(acount.getName())) {
            return ResultMsg.errorMsg("用户名为空");
        }
        if (StrUtil.isBlank(acount.getPasswd())) {
            return ResultMsg.errorMsg("密码为空");
        }
        if (!Validator.isEmail(acount.getEmail())) {
            return ResultMsg.errorMsg("邮箱不正确");
        }
        if (StrUtil.isBlank(acount.getConfirmPasswd())) {
            return ResultMsg.errorMsg("确认密码为空");
        }
        if (!StrUtil.equals(acount.getPasswd(), acount.getConfirmPasswd())) {
            return ResultMsg.errorMsg("密码和确认密码不相同");
        }
        if (acount.getType() == 0) {
            return ResultMsg.errorMsg("类型没有选择");
        }
        if (acount.getType() == 2 && StrUtil.isBlank(acount.getAgencyName())) {
            return ResultMsg.errorMsg("房产经纪没有没有选择");
        }
        return ResultMsg.successMsg("");
    }
}
